package dom.xpath.query.xpath.locpath;

import dom.xpath.data.Data;
import dom.xpath.query.xpath.XPContext;
import dom.xpath.query.xpath.values.NodeBuilder;

/**
 * Axis Step.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-07, ISC License
 * @author Tim Petrowsky
 * @author Christian Gruen
 */
public final class StepParent extends Step {
  @Override
  protected void eval(final Data data, final int p, final NodeBuilder t) {
    if(p == 0) return;
    final int pre = data.parent(p, data.kind(p));
    test.eval(data, pre, data.kind(pre), t);
  }

  @Override
  protected void pos(final XPContext ctx, final Data data, final int p) {
    eval(data, p, result);
  }

  @Override
  protected void early(final XPContext ctx, final Data data, final int p) {
    eval(data, p, result);
  }
}
